using System;
using Terra.Core.Common.Models.Pagination;

namespace Terra.Service.Logging.DTOs;

/// <summary>
/// 登录日志基础信息
/// </summary>
public abstract class LoginLogBase
{
    /// <summary>
    /// 用户名
    /// </summary>
    public string UserName { get; set; }

    /// <summary>
    /// 登录状态
    /// </summary>
    public bool Status { get; set; }

    /// <summary>
    /// IP地址
    /// </summary>
    public string IpAddress { get; set; }

    /// <summary>
    /// 错误信息
    /// </summary>
    public string ErrorMessage { get; set; }

    /// <summary>
    /// 登录方式
    /// </summary>
    public string LoginMethod { get; set; }

    /// <summary>
    /// 浏览器信息
    /// </summary>
    public string Browser { get; set; }

    /// <summary>
    /// 操作系统
    /// </summary>
    public string OS { get; set; }
}

/// <summary>
/// 登录日志DTO
/// </summary>
public class LoginLogDto : LoginLogBase
{
    /// <summary>
    /// 日志ID
    /// </summary>
    public Guid Id { get; set; }

    /// <summary>
    /// 登录时间
    /// </summary>
    public DateTime LoginTime { get; set; }
}

/// <summary>
/// 创建登录日志请求
/// </summary>
public class CreateLoginLogRequest : LoginLogBase
{
    /// <summary>
    /// 用户代理
    /// </summary>
    public string UserAgent { get; set; }

    public CreateLoginLogRequest()
    {
        LoginMethod = "Password"; // 默认使用密码登录
    }
}

/// <summary>
/// 登录日志分页查询请求
/// </summary>
public class LoginLogPagedRequest : PagedRequest
{
    /// <summary>
    /// 用户名(可选)
    /// </summary>
    public string UserName { get; set; }

    /// <summary>
    /// 登录状态(可选)
    /// </summary>
    public bool? Status { get; set; }

    /// <summary>
    /// 开始时间(可选)
    /// </summary>
    public DateTime? StartTime { get; set; }

    /// <summary>
    /// 结束时间(可选)
    /// </summary>
    public DateTime? EndTime { get; set; }
}